package com.sc.web.system;

import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;

import javax.servlet.http.HttpServletRequest;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import com.sc.dal.mapper.system.LogMapper;
import com.sc.dal.model.ParamMap;
import com.sc.dal.model.system.Log;
import com.sc.util.data.DataUtil;
import com.sc.util.exception.ExceptionEnum;
import com.sc.web.BaseController;
import com.sc.web.plugin.PageView;


/**
 * 
 * @author numberONe 2014-11-19
 * @version 3.0v
 */
@Controller
@RequestMapping("/log/")
public class LogController extends BaseController {
	
	@Autowired
	private LogMapper logMapper;
	

	@RequestMapping("list")
	public String listUI(Model model) throws Exception {
		return "/system/log/list";
	}

	@ResponseBody
	@RequestMapping("findByPage")
	public PageView findByPage( String pageNow,
			String pageSize,String column,String sort,HttpServletRequest request) throws Exception {
		Map<String, Object> resultMap = new LinkedHashMap<String, Object>();
		try {
			ParamMap paramMap = getFormMap(ParamMap.class);
			paramMap = toFormMap(paramMap, pageNow, pageSize, paramMap.getStr("orderby"));
			paramMap.put("column", column);
			paramMap.put("sort", sort);
			List<Log> records = logMapper.queryLogList(paramMap);
			pageView.setRecords(records);
			DataUtil.handleResultMap(resultMap, ExceptionEnum.DATA_SUCCESS);
			
		} catch (Exception e) {
			DataUtil.handleResultMap(resultMap, ExceptionEnum.DATA_SELECT);
		}
		
		
		return pageView;
		
	}
}